/*
The pseudo code can be cound in page 18.
*/

#include <iostream>
using namespace std;

int A[5] = {5,4,10,7,13};

void insert_sort(int *array, int len)
{
	int j=1;
	for(j=1;j<len;j++)
	{
		int key=array[j];
		int i;
		i=j-1;
		while((array[i]>key) && (i>=0))
		{
//			if(array[i]>key)
			{
				array[i+1]=array[i];
				i--;
			}
		}
		array[i+1] = key;
	}
	return;
}

int main()
{
	insert_sort(A,5);
//test
	int i;
	for(i=0;i<5;i++)
		cout<<A[i]<<" ";
	cout << endl;
	return 0;
}
